;;=========================================
;; Sick of typing the same damn code in over and over and over, and
;;   looking for the same damn typos.

PRO SR_BARS, array, grsmatch, minval, maxval, step, xp, yp, yp2
  
  hstep = step / 2.d
  ni = fix(round((maxval-minval) / step))
  nsucc = lonarr(ni)
  xp    = fltarr(ni)
  yp    = fltarr(ni)
  yp2   = fltarr(ni)
  FOR i=0, ni-1 DO BEGIN
     np = minval + step + i*step
     ind = WHERE(array LE np AND array GT np - step, nind)
     nind2 = 0
     IF nind GT 0 THEN BEGIN
        bar = grsmatch[ind]
        ind2 = WHERE(bar EQ 1, nind2)
     ENDIF
     yp[i] = (nind NE 0) ? float(nind2)/float(nind) : 0.
     yp2[i] = float(nind)
     xp[i] = np - hstep
  ENDFOR
  ;; Extend histogram so it goes to y=0 at both ends
  xp  = [minval-hstep,xp,maxval+hstep]
  yp  = [0,yp,0]
  yp2 = [0,yp2,0]
  
END
